<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	String prid = request.getParameter("prid");
%>
<style>
	div.operBoard {
		display:none;
		float:	left;
		left:	15px;
		right:	15px;
		top:	60px;
		bottom:	47px;
		z-index:	1000;
		position:	absolute;
		background-color:	#ffffff;
	}
</style>
<div style="width:850px;">
	<div id="superviseBoard" class="operBoard">
	<form>
		<input type="hidden" id="prid" value="<%=prid %>"/>
		<table class="layout">
			<tr>
				<td>项目名称：</td>
				<td><span id="superviseNum" class=""></span></td>
				<td>目标单位：</td>
				<td><input type="text" id="creOrg" class=""/></td>
			</tr>
			<tr>
				<td>发起时间：</td>
				<td><input type="text" id="creDate" class=""/></td>
				<td>完成时间：</td>
				<td><input type="text" id="creDate" class=""/></td>
			</tr>
			
			<tr>
				<td>督办内容：</td>
				<td colspan="3"><textarea id="remark"></textarea></td>
			</tr>
			<tr>
				<td></td>
				<td><input type="button" id="addDoc" value="保存"/></td>
				<td></td>
				<td><input type="button" id="backSup" value="返回"/></td>
			</tr>
		</table>
	</form>
	</div>
	<div id="viewBoard2" class="operBoard">
	<form>
		<input type="hidden" id="prid" value="<%=prid %>"/>
		<table class="layout">
			<tr>
				<td>项目名称：</td>
				<td><span id="view_supName" class=""></span></td>
				<td>目标单位：</td>
				<td><span id="view_supToOrg" class=""></span></td>
			</tr>
			<tr>
				<td>发起时间：</td>
				<td><span id="view_supCreDate" class=""></span></td>
				<td>完成时间：</td>
				<td><span id="view_supFinishDate" class=""></span></td>
			</tr>
			<tr>
				<td>督办内容：</td>
				<td colspan="3"><span id="view_supContent"></span></td>
			</tr>
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td><input type="button" id="view_backSup" value="返回"/></td>
			</tr>
		</table>
	</form>
	</div>
	<div id="editBoard2" class="operBoard">
	<form>
		<input type="hidden" id="prid" value="<%=prid %>"/>
		<table class="layout">
			<tr>
				<td>项目名称：</td>
				<td><input id="edit_supName" class="" value=""></input></td>
				<td>目标单位：</td>
				<td><input id="edit_supToOrg" class=""></input></td>
			</tr>
			<tr>
				<td>发起时间：</td>
				<td><input id="edit_supCreDate" class=""></input></td>
				<td>完成时间：</td>
				<td><input id="edit_supFinishDate" class=""></input></td>
			</tr>
			<tr>
				<td>督办内容：</td>
				<td colspan="3"><input id="edit_supContent"></input></td>
			</tr>
			<tr>
				<td></td>
				<td><input type="button" id="addDoc" value="保存"/></td>
				<td></td>
				<td><input type="button" id="edit_backSup" value="返回"/></td>
			</tr>
		</table>
	</form>
	</div>
	<div id="progressBoard" class="operBoard">
	<form>
		<input type="hidden" id="prid" value="<%=prid %>"/>
		<table class="layout">
			<tr>
				<td>状态：</td>
				<td><select>
					<option selected>未完成</option>
					<option>已完成</option>
				</select></td>
			</tr>
			<tr>
				<td>备注：</td>
				<td><textarea id="remark"></textarea></td>
			</tr>
			<tr>
				<td></td>
				<td><input type="button" id="addDoc" value="保存"/></td>
				<td></td>
				<td><input type="button" id="progress_backSup" value="返回"/></td>
			</tr>
		</table>
	</form>
	</div>
	<div class="doclist" id="superviseHistory">
		
		<div class="tableTitle">批准文号</div>
		<table class="listTable cssrain" style="width:100%;">
			<thead>
				<tr>
					<th colspan="3">
						<input type="button" id="newSup" value="新增"/>
						<input type="button" id="delDocs" value="删除" disabled="disabled"/>
					</th>
					<th colspan="8">
						<input type="text" size="40"/>
						<input type="button" value="查询"/>
						<input type="button" value="高级查询"/>
					</th>
				</tr>
				<tr>
					<th><input id="checkboxAll" type="checkbox"/></th>
					<th>项目名称</th>
					<th>督办人</th>
					<th>目标单位</th>
					<th>督办内容</th>
					<th>发起时间</th>
					<th>完成时间</th>
					<th>实际完成时间</th>
					<th>状态</th>
					<th>操作</th>
					<th>备注</th>
					
				</tr>
			</thead>
			<tbody></tbody>
		</table>
		<div class="pages">
			<div class="pagesL">&nbsp;&nbsp;&nbsp;&nbsp;共<strong id="total"> 180</strong> 条记录&nbsp;&nbsp;<strong> 15</strong> 条/页，当前第<strong> 1</strong> 页</div>
			<div class="pagesC">◀◀上一页&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;2&nbsp;3&nbsp;4&nbsp;5&nbsp;...&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;下一页▶▶</div>
			<div class="pagesR">转到&nbsp; <input type="text" style="width:25px; height:12px; font-size:12px; border:solid 1px #7aaebd;"/>&nbsp;&nbsp;页&nbsp;&nbsp;&nbsp;</div>
		</div>
	</div>
</div>
<script type="text/javascript">

	// For Demo
	var prid = $("#prid").val();
	var docs = window.parent.mem.supervise[prid];
	var projList = window.parent.mem.projInfo;
	tbodyHtml = "";
	var doc;
	var today = new Date();
	var count = 0;
	if (docs) {
		for (var id in docs) {
			doc = docs[id];
			if (count < 5) {
				
				tbodyHtml += "<tr><td><input type='checkbox' class='recSelect' value='"+doc.id+"'/>"
					+"</td><td>"+projList[prid]["projName"]
	   				+"</td><td>"+doc.supervisor
	   				+"</td><td>"+doc.targetOrg
	   				+"</td><td>"+doc.content
					+"</td><td>"+doc.creDate.toStdDateTimeString()
					+"</td><td>"+doc.endDate.toStdDateString()
					+"</td><td>"+(doc.finishDate == null ? "-" : doc.finishDate.toStdDateTimeString())
					+"</td><td>"+doc.status
					+'</td><td><a class="editSup">编辑</a> '+(doc.status == "已完成" ? "" : '<a class="updateProgress">更新进度</a>')
					+ '</td><td></td></tr>';
			}
			count++;
		}
	}
	for (;count < 5; count++) {
		tbodyHtml += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
	}
	$("#superviseHistory > .listTable > tbody").html(tbodyHtml);
	$("#superviseHistory > .pages > .pagesL > #total").html(count);


	function displaySupInfo(doc) {
		$("#view_supName").html(projList[prid]["projName"]);
		$("#view_supToOrg").html(doc.targetOrg);
		$("#view_supCreDate").html(doc.creDate.toStdDateTimeString());
		$("#view_supFinishDate").html(doc.endDate.toStdDateTimeString());
		$("#view_supContent").html(doc.content);
	}

	function displaySupEditForm(doc) {
		$("#edit_supName").val(projList[prid]["projName"]);
		$("#edit_supToOrg").val(doc.targetOrg);
		$("#edit_supCreDate").val(doc.creDate.toStdDateTimeString());
		$("#edit_supFinishDate").val(doc.endDate.toStdDateTimeString());
		$("#edit_supContent").val(doc.content);
	}
</script>
<script type="text/javascript">
	var prid = $("#prid").val();
	var docs = window.parent.mem.supervise[prid];
	// record double-click event
	$('#superviseHistory .cssrain tbody').delegate("tr", "dblclick", function(evt) {
		var appid = $(this).find('input.recSelect').val();
		var doc = docs[appid];
		displaySupInfo(doc);
		$("#viewBoard2").css("display", "inline");
	});

	$("#backSup").click(function(evt) {
		$("#superviseBoard").css("display", "none");
	});
	
	// "back" button in viewBoard.
	$("#view_backSup").click(function(evt) {
		$("#viewBoard2").css("display", "none");
	});

	$("#newSup").click(function() {
		$("#superviseBoard").css("display", "inline");
	});

	$("#addDoc").click(function() {
		
		$.simpleTip('成功保存');
		
		$("#manager").load("<%=basePath%>admin/planList.jsp");
	});

	$(".editSup").click(function() {
		var appid = $(this).parent().parent().find('input.recSelect').val();
		var doc = docs[appid];
		displaySupEditForm(doc);
		$("#editBoard2").css("display", "inline");
	});

	$("#edit_backSup").click(function(evt) {
		$("#editBoard2").css("display", "none");
	});

	$(".updateProgress").click(function() {
		$("#progressBoard").css("display", "inline");
	});

	$("#progress_backSup").click(function(evt) {
		$("#progressBoard").css("display", "none");
	});
</script>